package br.edu.unipampa.util;

import org.andengine.engine.Engine;
import org.andengine.engine.camera.Camera;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.texture.TextureOptions;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.region.TextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import br.edu.unipampa.principal.GameActivity;

public class ResourcesManager {
	private static ResourcesManager INSTANCE = new ResourcesManager();
	
	public Engine engine;
	public GameActivity activity;
	public Camera camera;
	public VertexBufferObjectManager vbom;
	
	// texturas menu
	public TextureRegion textCriarPartida;
	public TextureRegion textConectarPartida;
	public TextureRegion textSair;
	public TextureRegion textBackground;
	
	public TextureRegion textSplashScreen;
	public BitmapTextureAtlas imgSplashScreen;
	
	public void loadResourcesMenu(){
		loadMenuGraphics();
		loadMenuAudio();
	}

	public void loadSplashScreen(){
		BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
		imgSplashScreen = new BitmapTextureAtlas(activity.getTextureManager(), 400, 480, TextureOptions.BILINEAR);
		textSplashScreen = BitmapTextureAtlasTextureRegionFactory.createFromAsset(imgSplashScreen, activity, "logo.png",0,0);
		imgSplashScreen.load();
	}
	
	public void unloadSplashScreen(){
		imgSplashScreen.unload();
		textSplashScreen = null;
	}
	
	public void loadResourcesCriaPartida(){
		
	}
	
	public void loadResourcesConectaPartida(){
		
	}
	
	public void loadResourcesGame(){
		
	}
	
	public void loadResourcesResultado(){
		
	}
	
	private void loadMenuAudio() {
		
	}

	private void loadMenuGraphics() {
		BitmapTextureAtlas imgCriarPartida;
		BitmapTextureAtlas imgConectarPartida;
		BitmapTextureAtlas imgSair;
		BitmapTextureAtlas imgBackground;
		
		imgCriarPartida = new BitmapTextureAtlas(activity.getTextureManager(), 200, 120);
		textCriarPartida = BitmapTextureAtlasTextureRegionFactory.createFromAsset(imgCriarPartida, activity, "menu_criar_partida.png",0,0);
		imgCriarPartida.load();
		
		imgConectarPartida = new BitmapTextureAtlas(activity.getTextureManager(), 200, 120);
		textConectarPartida = BitmapTextureAtlasTextureRegionFactory.createFromAsset(imgConectarPartida, activity, "menu_conectar_partida.png",0,0);
		imgConectarPartida.load();
		
		imgSair = new BitmapTextureAtlas(activity.getTextureManager(), 200, 120);
		textSair = BitmapTextureAtlasTextureRegionFactory.createFromAsset(imgSair, activity, "menu_sair.png",0,0);
		imgSair.load();
		
		imgBackground = new BitmapTextureAtlas(activity.getTextureManager(), 800, 480);
		textBackground = BitmapTextureAtlasTextureRegionFactory.createFromAsset(imgBackground, activity, "background.png",0,0);
		imgBackground.load();
	}
	
	public static void prepareManager(Engine engine, GameActivity activity, Camera camera, VertexBufferObjectManager vbom){
		getInstance().engine = engine;
		getInstance().activity = activity;
		getInstance().camera = camera;
		getInstance().vbom = vbom;
	}
	
	public static ResourcesManager getInstance()
    {
        return INSTANCE;
    }
}
